package com.andrew.demo.mapper;

import com.andrew.demo.model.BaseDbEntity;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
public class MapperHelper {

    public static Map<String, BaseMapper> mapperMap = new HashMap<>();

    static {
        mapperMap.put("userMapper", new UserMapper());
        mapperMap.put("studentMapper", new StudentMapper());
    }

    public static BaseMapper getRowMapperByClass(String name) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
        String key = name.toLowerCase();
        key = key + "Mapper";
        System.out.println(key + "===================");
        BaseMapper mapper = mapperMap.get(key);
        if (mapper == null) {
            // todo 在这里做一个异常处理累
        }
        return mapper;
    }
}
